package com.bys.admin.ai.mapper;

import java.util.*;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bys.admin.ai.controller.vo.ChatModelPageReqVO;
import com.bys.admin.ai.entity.ChatModel;
import com.bys.vo.PageVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.base.MPJBaseMapper;

import org.apache.ibatis.annotations.Mapper;

/**
 * ai 聊天模型 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ChatModelMapper extends MPJBaseMapper<ChatModel> {

    default Page<ChatModel> selectPage(ChatModelPageReqVO reqVO) {
        return selectPage(new Page<ChatModel>(reqVO.getPageNo(),reqVO.getPageSize()),new LambdaQueryWrapper<ChatModel>()
                .eq(Objects.nonNull(reqVO.getKeyId()),ChatModel::getKeyId, reqVO.getKeyId())
                .like(StrUtil.isNotBlank(reqVO.getName()),ChatModel::getName, reqVO.getName())
                .eq(StrUtil.isNotBlank(reqVO.getModel()),ChatModel::getModel, reqVO.getModel())
                .eq(StrUtil.isNotBlank(reqVO.getPlatform()),ChatModel::getPlatform, reqVO.getPlatform())
                .eq(Objects.nonNull(reqVO.getStatus()),ChatModel::getStatus, reqVO.getStatus())
                .eq(Objects.nonNull(reqVO.getStatus()),ChatModel::getTemperature, reqVO.getTemperature())
                .eq(ChatModel::getMaxTokens, reqVO.getMaxTokens())
                .eq(ChatModel::getMaxContexts,reqVO.getMaxContexts()));
    }
}